<?php
// Création des tables
$tables_names = Array(	'clients',
						'machines',
						'contacts',
						'branches',
						'modeles',
						'commentaires',
						'zones',
						'utilisateurs',
						'rapports',
						'actions',
						'participants'
					);
					
foreach($tables_names as $table){
	${'tbl_'.$table} = new BpdTable($table);
	$tables[$table] = ${'tbl_'.$table};
}

// Table Clients
$tbl_clients->AddField( new BpdField('id', INTEGER, 0), KEY );
$tbl_clients->AddField( new BpdField('nom', VARCHAR, 25));

// Table contacts
$tbl_contacts->AddField( new BpdField('id', INTEGER, 0), KEY );
$tbl_contacts->AddField( new BpdField('prenom', VARCHAR, 25) );
$tbl_contacts->AddField( new BpdField('nom', VARCHAR, 25) );
$tbl_contacts->AddRelTo1($tbl_clients);
$tbl_contacts->SetLabel("CONCAT(con_id,' - ',CASE con_prenom
WHEN NULL THEN con_nom
ELSE CONCAT_WS(', ',con_nom, con_prenom)
END)");

// Table Machines
$tbl_machines->AddRelTo1($tbl_clients);

/*
$tbl_clients->AddField('nom', EDITABLE, VISIBLE);

$tbl_branches->AddField('code', EDITABLE, VISIBLE);
$tbl_branches->AddField('nom', EDITABLE, VISIBLE);

$tbl_zones->AddField('code', EDITABLE, VISIBLE);
$tbl_zones->AddField('nom', EDITABLE, VISIBLE);

$tbl_utilisateurs->AddField('code', EDITABLE, VISIBLE);
$tbl_utilisateurs->AddField('nom', EDITABLE, VISIBLE);
$tbl_utilisateurs->AddField('prenom', EDITABLE, VISIBLE);

$tbl_modeles->AddField('code', EDITABLE, VISIBLE);


$tbl_clients->AddRelInt($tbl_branches);
$tbl_clients->AddRelInt($tbl_zones);
$tbl_clients->AddRelInt($tbl_utilisateurs);

$tbl_rapports->AddRelInt($tbl_clients);
$tbl_rapports->AddRelInt($tbl_utilisateurs);

$tbl_actions->AddRelInt($tbl_rapports);
$tbl_actions->AddRelInt($tbl_utilisateurs);

$tbl_participants->AddRelInt($tbl_rapports);

$tbl_machines->AddRelInt($tbl_modeles);
$tbl_machines->AddRelInt($tbl_clients);

$tbl_commentaires->AddRelInt($tbl_clients);
$tbl_commentaires->AddRelInt($tbl_utilisateurs);

$tbl_contacts->AddRelInt($tbl_clients);
*/
?>
